import tool from '@/utils/tool'

/**
 * 转换数据为枚举对象
 * @param {*} value 参数
 */
const toEnum = (value) => {
	return Object.fromEntries(
		value.map((item) => {
			const arr = []
			arr[0] = item.value
			arr[1] = item.label
			return arr
		})
	)
}

// 签约方式
const signMethodOptions = [
	{ label: '电子合同', value: '0' },
	{ label: '纸质合同', value: '1' }
]
// 组装签约场景枚举
const signMethodEnum = toEnum(signMethodOptions)

// 签约场景
const signPayOptions = tool.dictList('SignPayment')
// 组装签约场景枚举
const signPayEnum = toEnum(signPayOptions)

// 收款方式
const payMethodOptions = tool.dictList('PAYMENT_METHOD')
const payMethodEnum = toEnum(payMethodOptions)

// 业务类型
const businessOptions = tool.dictList('BUSINESS_TYPE')
// 业务类型枚举
const businessEnum = toEnum(businessOptions)

// 合同状态
const businessApproveOptions = tool.dictList('APPROVAL_STATUS')
// 节点状态枚举
const statusEnum = toEnum(businessApproveOptions)

// 客户录入方式选项和枚举
const customerRecord = tool.dictList('CUSTOMER_RECORD_TYPE')
const customerRecordEnum = toEnum(customerRecord)

// 外呼结果选项和枚举
// const callStatusOptions = tool.dictList('OUTBOUND_RESULT')
const callStatusOptions = [
	{ label: '已接通', value: 1 },
	{ label: '未接通', value: 0 }
]
const callStatusEnum = toEnum([...callStatusOptions, { label: '未呼叫', value: null }])

// 业务财务状态
const appStatusOptions = tool.dictList('FinanceApprovalStatus')
const approvalStatusEnum = toEnum(appStatusOptions)

// 跟进类型
const followOptinos = tool.dictList('FOLLOW')
const followTypeEnum = toEnum(followOptinos)

// 跟进状态
const followUpOptions = [
	{ label: '未跟进', value: 0 },
	{ label: '跟进中', value: 1 },
	{ label: '已成交', value: 2 }
]
const followUpEnum = toEnum(followUpOptions)
const followUpMap = followUpOptions.reduce((total, item) => ({ ...total, [item.value]: item.label }), {})

// 补款状态
const payStatusOptions = [
	{ label: '未补款', value: '0' },
	{ label: '部分补款', value: '1' },
	{ label: '已补款', value: '2' }
]
const payStatusEnum = toEnum(payStatusOptions)

// 合同类型
const contractTypeOptions = tool.dictList('CONTRACTTYPE')
const contractTypeEnum = toEnum(contractTypeOptions)

// 转换类型
const transTypeOptions = [
	{ label: '无转换', value: '0' },
	{ label: '部分转换', value: '1' },
	{ label: '全部转换', value: '2' }
]
const transTypeEnum = toEnum(transTypeOptions)

// 订单状态
const orderStatusOptions = tool.dictList('ORDER_STATUS')
const orderStatusEnum = toEnum(orderStatusOptions)

// 通信方式
const communicationTypeOptions = [
	{ label: '线路外呼', value: '0' },
	{ label: '4G多卡话机', value: '1' }
]
const communicationTypeEnum = toEnum(communicationTypeOptions)

// 通信对象
const communicationObjectOptions = [
	{ label: '线索', value: '1' },
	{ label: '客户', value: '0' }
]
const communicationObjectEnum = toEnum(communicationObjectOptions)

export {
	signMethodOptions,
	signMethodEnum,
	signPayOptions,
	signPayEnum,
	payMethodEnum,
	businessEnum,
	statusEnum,
	customerRecord,
	customerRecordEnum,
	callStatusOptions,
	callStatusEnum,
	appStatusOptions,
	approvalStatusEnum,
	followTypeEnum,
	followUpOptions,
	followUpEnum,
	followUpMap,
	payStatusOptions,
	payStatusEnum,
	contractTypeOptions,
	contractTypeEnum,
	transTypeOptions,
	transTypeEnum,
	orderStatusOptions,
	orderStatusEnum,
	communicationTypeOptions,
	communicationTypeEnum,
	communicationObjectOptions,
	communicationObjectEnum
}
